#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <string.h>

using namespace std;

void sig_handler(int signo)
{
    cout << "正在处理" << signo << "号信号，请稍等..." << endl;
    sleep(3);
}

int main()
{
    struct sigaction act;
    act.sa_handler = sig_handler;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask, 3);
    sigaction(2, &act, nullptr);
    while (true)
    {
        cout << "I'm a process.My pid is " << getpid() << endl;
        sleep(1);
    }
    return 0;
}